﻿Public Class FTPembagianKelas

    'MEMBER variables
    Private _cSemester As CSemester
    Private _idSemesterLalu As Integer
    Private _idSemesterSekarang As Integer
    Private _ckelas As CKelas

    'form
    Private WithEvents _flSemesterKiri As FLSemester
    Private WithEvents _flSemesterKanan As FLSemester

    Public Sub New()

        ' This call is required by the designer.
        InitializeComponent()

        ' Add any initialization after the InitializeComponent() call.
        Me.Text = My.Settings.NamaAplikasi & " [Pembagian Kelas]"
    End Sub

    Private Sub btnProses_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnProses.Click
        'PROSES MULAI
        tbSemesterlalu.Enabled = False
        cbTingkatanLalu.Enabled = False
        btnKanan.Enabled = True
        btnKanan2.Enabled = True
        btnkiri.Enabled = True
        btnKiri2.Enabled = True
        btnProses.Enabled = False
        btnBatal.Enabled = True
        btnSimpan.Enabled = True
    End Sub

    Private Sub btnBatal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBatal.Click
        'PROSES BATTAL
        tbSemesterlalu.Enabled = True
        cbTingkatanLalu.Enabled = True
        btnKanan.Enabled = False
        btnKanan2.Enabled = False
        btnkiri.Enabled = False
        btnKiri2.Enabled = False
        btnProses.Enabled = True
        btnBatal.Enabled = False
        btnSimpan.Enabled = False
    End Sub

    Private Sub FTPembagianKelas_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'set semester 
        _cSemester = New CSemester
        Dim _dTabSemesterAktif As DataTable = _cSemester.getSemesterAktif
        _idSemesterLalu = _dTabSemesterAktif(0).Item("id")
        _idSemesterSekarang = _dTabSemesterAktif(0).Item("id")
        tbSemesterlalu.Text = _dTabSemesterAktif(0).Item("nama")
        tbSemesterSekarang.Text = _dTabSemesterAktif(0).Item("nama")

        
    End Sub

    Private Sub tbSemesterlalu_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles tbSemesterlalu.Click
        _flSemesterKiri = New FLSemester
        _flSemesterKiri.ShowDialog()
    End Sub

    Private Sub tbSemesterSekarang_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles tbSemesterSekarang.Click
        _flSemesterKanan = New FLSemester
        _flSemesterKanan.ShowDialog()
    End Sub

    Private Sub _flSemesterKanan_DataTerpilih() Handles _flSemesterKanan.DataTerpilih
        _idSemesterSekarang = _flSemesterKanan.SelectedIDSemester
        tbSemesterSekarang.Text = _flSemesterKanan.SelectedNamaSemester
    End Sub

    Private Sub _flSemesterKiri_DataTerpilih() Handles _flSemesterKiri.DataTerpilih
        _idSemesterLalu = _flSemesterKiri.SelectedIDSemester
        tbSemesterlalu.Text = _flSemesterKiri.SelectedNamaSemester
    End Sub

    Private Sub cbTingkatanLalu_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbTingkatanLalu.SelectedIndexChanged
        If cbTingkatanLalu.SelectedIndex > 0 Then
            'TAMPILKAN KELAS
            'set combo box kelas
            _ckelas = New CKelas
            cbKelas.Enabled = True
            With cbKelas
                .DataSource = _ckelas.getByTingakatan(cbTingkatanLalu.SelectedIndex)
                .DisplayMember = "nama"
                .ValueMember = "id"
            End With
        Else
            cbKelas.Enabled = False
        End If

    End Sub

    Private Sub cbKelas_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbKelas.SelectedIndexChanged
        If cbKelas.Items.Count > 0 Then
            'MENAMPILKAN DAFTAR SISWA

        End If
    End Sub
End Class